Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport v0.1 - PR #177 - Fix streaming functionality with Bedrock guardrails (#176) #231

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

ardf
Copy link
Contributor

@ardf ardf commented Oct 10, 2024

This PR addresses an issue where the streaming functionality in ChatBedrock breaks when Bedrock guardrails are applied. The problem was caused by a KeyError in the _stream_response_to_generation_chunk method when trying to access the 'stop_sequence' key, which may not always be present in the response structure when guardrails are active.

Changes

  • Modified the _stream_response_to_generation_chunk method in llms/bedrock.py to use the get() method when accessing dictionary keys that may not always be present.

Testing

  • Tested the streaming functionality with and without Bedrock guardrails applied.
  • Verified that the streaming works correctly in both scenarios without raising KeyErrors.

langchain-ai#177)

This PR addresses an issue where the streaming functionality in
ChatBedrock breaks when Bedrock guardrails are applied. The problem was
caused by a KeyError in the `_stream_response_to_generation_chunk`
method when trying to access the 'stop_sequence' key, which may not
always be present in the response structure when guardrails are active.

## Changes
- Modified the `_stream_response_to_generation_chunk` method in
`llms/bedrock.py` to use the `get()` method when accessing dictionary
keys that may not always be present.


## Testing
- Tested the streaming functionality with and without Bedrock guardrails
applied.
- Verified that the streaming works correctly in both scenarios without
raising KeyErrors.
@ardf ardf changed the title Fix streaming functionality with Bedrock guardrails (#176) (#177) Backport v0.1 - PR #177 - Fix streaming functionality with Bedrock guardrails (#176) Oct 10, 2024
@3coins 3coins merged commit 647e8b2 into langchain-ai:v0.1 Oct 11, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants